package com.live.controller;

import com.common.entity.live.TbLive;
import com.common.response.CommonResponse;
import com.github.pagehelper.PageInfo;
import com.live.service.ILiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LiJinYang
 * @version 1.0
 * @email 283006176@qq.com
 * @date 2021/08/11 9:25
 */
@RestController
@RequestMapping("/live")
@CrossOrigin
public class LiveController {

    @Autowired
    private ILiveService liveService;

    /**
     * 直播列表（模糊）
     * @param tbLive
     * @param page
     * @param size
     * @return
     */
    @PostMapping("/findPage")
    public PageInfo findPage(@RequestBody TbLive tbLive
            , @RequestParam(value = "page",defaultValue = "1")int page
            , @RequestParam(value = "size",defaultValue = "10")int size){
        return liveService.findPage(tbLive,page,size);
    }

    /**
     * 修改直播状态
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/updateStatusById")
    public CommonResponse updateStatusById(@RequestParam("id")Long id, @RequestParam("status")String status){
        return liveService.updateStatusById(id,status);
    }

    /**
     * 查询当前直播信息
     * @param id
     * @return
     */
    @GetMapping("/findOne")
    public TbLive findOne(Long id){
        return liveService.findOne(id);
    }
}
